package com.yhsimon.mediator.smarthouse;

/**
 * @author： YHSimon
 * @date： 2021-10-19 09:47
 */
public class CoffeeMachine extends Colleague {
    public CoffeeMachine(Mediator mediator, String name) {
        super(mediator, name);
        //在创建同事对象时，将自己放入到ConcreteMediator
        mediator.register(name, this);
    }


    public void startCoffee() {
        System.out.println("It's time to startCoffee !");
    }

    public void finishCoffee() {
        System.out.println("After 5 minutes!");
        System.out.println("Coffee is ok!");
        sendMessage(0);
    }

    public void sendMessage(int stateChange) {
        //调用的中介者对象的getMessage
        this.getMediator().getMessage(stateChange, this.name);
    }
}
